﻿
<template>
<div class="card-fill layout-padding">
<el-card shadow="hover" class="layout-padding-auto" >
  <WtmSearcher v-model="searchDataQcSheet" @search="()=>{getTableDataQcSheet();}">
      <el-row>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="WoId_FormItem" prop="WoId" :label="$t('message.autotrans._Model_QcSheet_WoId')">
            <el-input v-model="searchDataQcSheet.WoId" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="WoCode_FormItem" prop="WoCode" :label="$t('message.autotrans._Model_QcSheet_WoCode')">
            <el-input v-model="searchDataQcSheet.WoCode" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="ProductId_FormItem" prop="ProductId" :label="$t('message.autotrans._Model_QcSheet_ProductId')">
            <el-input v-model="searchDataQcSheet.ProductId" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="ProductName_FormItem" prop="ProductName" :label="$t('message.autotrans._Model_QcSheet_ProductName')">
            <el-input v-model="searchDataQcSheet.ProductName" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="QcMode_FormItem" prop="QcMode" :label="$t('message.autotrans._Model_QcSheet_QcMode')">
            <el-select v-model="searchDataQcSheet.QcMode" clearable>
               <el-option key="IQC" value="IQC" :label="$t('message.autotrans._Enum_QcModeEnum_IQC')"></el-option>
               <el-option key="IPQC" value="IPQC" :label="$t('message.autotrans._Enum_QcModeEnum_IPQC')"></el-option>
               <el-option key="FQC" value="FQC" :label="$t('message.autotrans._Enum_QcModeEnum_FQC')"></el-option>
               <el-option key="OQC" value="OQC" :label="$t('message.autotrans._Enum_QcModeEnum_OQC')"></el-option>
            </el-select>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="Sn_FormItem" prop="Sn" :label="$t('message.autotrans._Model_QcSheet_Sn')">
            <el-input v-model="searchDataQcSheet.Sn" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="TemplateId_FormItem" prop="TemplateId" :label="$t('message.autotrans._Model_QcSheet_Template')">
            <el-select v-model="searchDataQcSheet.TemplateId" clearable>
               <el-option v-for="item in stateQcSheet.AllTemplates" :key="item.Value" :value="item.Value" :label="item.Text"></el-option>
            </el-select>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="QcOperator_FormItem" prop="QcOperator" :label="$t('message.autotrans._Model_QcSheet_QcOperator')">
            <el-input v-model="searchDataQcSheet.QcOperator" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="QcResult_FormItem" prop="QcResult" :label="$t('message.autotrans._Model_QcSheet_QcResult')">
            <el-select v-model="searchDataQcSheet.QcResult" clearable>
               <el-option key="Ok" value="Ok" :label="$t('message.autotrans._Enum_QcStatusEnum_Ok')"></el-option>
               <el-option key="NG" value="NG" :label="$t('message.autotrans._Enum_QcStatusEnum_NG')"></el-option>
               <el-option key="Doing" value="Doing" :label="$t('message.autotrans._Enum_QcStatusEnum_Doing')"></el-option>
            </el-select>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="Remark_FormItem" prop="Remark" :label="$t('message.autotrans._Model_QcSheet_Remark')">
            <el-input v-model="searchDataQcSheet.Remark" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="CreateTime_FormItem" prop="CreateTime" :label="$t('message.autotrans._Model_QcSheet_CreateTime')">
            <el-date-picker v-model="searchDataQcSheet.CreateTime" type='daterange' clearable></el-date-picker>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="UpdateTime_FormItem" prop="UpdateTime" :label="$t('message.autotrans._Model_QcSheet_UpdateTime')">
            <el-date-picker v-model="searchDataQcSheet.UpdateTime" type='daterange' clearable></el-date-picker>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="CreateBy_FormItem" prop="CreateBy" :label="$t('message.autotrans._Model_QcSheet_CreateBy')">
            <el-input v-model="searchDataQcSheet.CreateBy" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="UpdateBy_FormItem" prop="UpdateBy" :label="$t('message.autotrans._Model_QcSheet_UpdateBy')">
            <el-input v-model="searchDataQcSheet.UpdateBy" clearable></el-input>
        </el-form-item>

        </el-col>
      </el-row>

  </WtmSearcher>

  <div style="text-align: right;">
      <WtmButton v-auth="'/api/QcManagement/QcSheet/Create'" icon='fa fa-plus' type='primary' :button-text="$t('message.autotrans.SysCreate')" @click="OnCreateClick()"/>
    <WtmButton v-auth="'/api/QcManagement/QcSheet/BatchDelete'"  icon='fa fa-trash' type='danger' :button-text="$t('message.autotrans.SysDelete')" :confirm="$t('message._system.common.vm.deletetip')" @click="onBatchDelete()"/>
    <WtmButton v-auth="'/api/QcManagement/QcSheet/BatchEdit'" icon='fa fa-pencil-square' type='primary' :button-text="$t('message.autotrans.SysBatchEdit')" @click="OnBatchEditClick()"/>
    <WtmButton v-auth="'/api/QcManagement/QcSheet/Import'" icon='fa fa-tasks' type='primary' :button-text="$t('message.autotrans.SysImport')" @click="OnImportClick()"/>
    <WtmButton v-auth="'/api/QcManagement/QcSheet/QcSheetExportExcel'"  icon='fa fa-arrow-circle-down' type='primary' :button-text="$t('message.autotrans.SysExport')" @click="onExport()"/>

  </div>
  <WtmTable ref="tableRefQcSheet" v-bind="tableDataQcSheet">
    <template #operation>
      <el-table-column :label="$t('message._system.common.vm.operate')" width="180">
        <template v-slot="scope">
            <WtmButton v-auth="'/api/QcManagement/QcSheet/Edit'" :is-text="true" icon='fa fa-pencil-square' type='warning' :button-text="$t('message.autotrans.SysEdit')" @click="OnEditrowClick(scope.row)"/>
          <WtmButton v-auth="'/api/QcManagement/QcSheet/{id}'" :is-text="true" icon='fa fa-info-circle' type='info' :button-text="$t('message.autotrans.Page详情')" @click="OnDetailsrowClick(scope.row)"/>
          <WtmButton v-auth="'/api/QcManagement/QcSheet/BatchDelete'"  icon='fa fa-trash' type='danger' :button-text="$t('message.autotrans.SysDelete')" :confirm="$t('message._system.common.vm.deletetip')" :is-text="true"  @click="onDelete(scope.row)"/>

        </template>
      </el-table-column>
    </template>
  </WtmTable>

</el-card>
</div>
</template>


<script setup lang="ts" name="message.autotrans._PageQcManagementQcSheetIndex;true;Digitalmes.QcManagement.Controllers;QcSheet">
import {  ElMessageBox, ElMessage,ElLoading } from 'element-plus';
import { defineAsyncComponent,reactive, ref, getCurrentInstance, onMounted, nextTick } from 'vue';
import { qcsheetApi } from '/@/api/qcmanagement/qcsheet';
import other from '/@/utils/other';
import fileApi from '/@/api/file';
import { useRouter } from "vue-router";
const ci = getCurrentInstance() as any;

const CreateDialog = defineAsyncComponent(() => import('./create.vue'));
const EditDialog = defineAsyncComponent(() => import('./edit.vue'));
const DetailsDialog = defineAsyncComponent(() => import('./details.vue'));
const BatchEditDialog = defineAsyncComponent(() => import('./batchedit.vue'));
const ImportDialog = defineAsyncComponent(() => import('./import.vue'));

const stateQcSheet = reactive({
    
    AllTemplates: [] as any[],
});

const searchDataQcSheet = ref({
        WoId: '',
        WoCode: '',
        ProductId: null,
        ProductName: '',
        QcMode: undefined,
        Sn: '',
        TemplateId: null,
        QcOperator: '',
        QcResult: undefined,
        Remark: '',
        CreateTime: undefined,
        UpdateTime: undefined,
        CreateBy: '',
        UpdateBy: '',
});

// 定义变量内容
const tableRefQcSheet = ref();
const tableDataQcSheet = ref({
    // 列表数据（必传）
    data: [],
	// 表头内容（必传，注意格式）
	header: [
      {title:ci.proxy.$t('message.autotrans.Page工单号'),key: 'QcSheet_WoId',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page工单编号'),key: 'QcSheet_WoCode',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page产品'),key: 'QcSheet_ProductId',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page产品名称'),key: 'QcSheet_ProductName',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page质检模式'),key: 'QcSheet_QcMode',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page追溯码'),key: 'QcSheet_Sn',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page检验模板'),key: 'QcSheet_Template',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page检验员'),key: 'QcSheet_QcOperator',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page检验结果'),key: 'QcSheet_QcResult',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans._AdminRemark'),key: 'QcSheet_Remark',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans._AdminCreateTime'),key: 'QcSheet_CreateTime',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans._AdminUpdateTime'),key: 'QcSheet_UpdateTime',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans._AdminCreateBy'),key: 'QcSheet_CreateBy',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans._AdminUpdateBy'),key: 'QcSheet_UpdateBy',type: 'text',isCheck: true},

	],
	// 配置项（必传）
	config: {
        total: 0, // 列表总数
		loading: true, // loading 加载
		isSerialNo: true, // 是否显示表格序号
		isSelection: true, // 是否显示表格多选
		isOperate: true, // 是否显示表格操作栏
	}
});
// 初始化表格数据
const getTableDataQcSheet = () => {
    tableRefQcSheet.value.doSearch(qcsheetApi().search, searchDataQcSheet.value)
        .catch((error: any) => {
			other.setFormError(ci, error);
		});
};
const OnCreateClick = () => {
    other.openDialog(ci.proxy.$t('message.autotrans.SysCreate'), CreateDialog, null, getTableDataQcSheet)
};

const OnEditrowClick = (row: any) => {
    other.openDialog(ci.proxy.$t('message.autotrans.SysEdit'), EditDialog, row, getTableDataQcSheet)
};

const OnDetailsrowClick = (row: any) => {
    other.openDialog(ci.proxy.$t('message.autotrans.Page详情'), DetailsDialog, row, getTableDataQcSheet)
};

// 删除
const onDelete = (row: any) => {
    qcsheetApi().delete([row.ID]).then(() => { getTableDataQcSheet()})
};

const onBatchDelete = () => {
    const selectedrows = tableRefQcSheet.value.getSelectedRows();
    const selectedids = selectedrows.map((x: any) => x.ID);
    if (selectedids.length > 0)
      qcsheetApi().delete(selectedids).then(() => { getTableDataQcSheet()})
    else
      ElMessage.error(ci.proxy.$t('message._system.common.vm.check'));
};

const OnBatchEditClick = () => {
    const selectedrows = tableRefQcSheet.value.getSelectedRows();
    const selectedids = selectedrows.map((x: any) => x.ID);
    if (selectedids.length > 0)
      other.openDialog(ci.proxy.$t('message.autotrans.SysBatchEdit'), BatchEditDialog, selectedids, getTableDataQcSheet)
    else
      ElMessage.error(ci.proxy.$t('message._system.common.vm.check'));
};

const OnImportClick = () => {
    other.openDialog(ci.proxy.$t('message.autotrans.SysImport'), ImportDialog, null, getTableDataQcSheet)
};

const onExport = () => {
	const selected = tableRefQcSheet.value.getSelectedRows();
	if (selected.length > 0) {
		qcsheetApi().exportById(selected.map((x: any) => x.ID));
	}
	else {
		qcsheetApi().export({});
	}
};

// 页面加载时
onMounted(() => {
    
    other.getSelectList('/api/QcManagement/QcSheet/GetQcTemplates',[],false).then(x=>{stateQcSheet.AllTemplates = x});
        getTableDataQcSheet();

});

// 暴露变量
defineExpose({

});
</script>

<style scoped lang="scss">

</style>

